#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([inotify-sync], [0.4.0], [leeyiw@gmail.com])
AM_INIT_AUTOMAKE(inotify-sync, 0.4.0)
AC_CONFIG_SRCDIR([src/inotify-sync.c])
AC_CONFIG_HEADERS([src/defines.h])

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

# Checks for libraries.
AC_CHECK_LIB([confuse], [cfg_init], ,
	AC_MSG_ERROR([libconfuse not found. try install libconfuse.]))
AC_CHECK_LIB([pthread], [pthread_create], ,
	AC_MSG_ERROR([pthread not found. try install pthread]))

# Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h stddef.h stdlib.h string.h syslog.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT32_T

# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([dup2 localtime_r strerror tzset])

AC_ARG_ENABLE([debug],
	[AS_HELP_STRING([--enable-debug], [compile with debug info])],
	[enable_debug="yes"],
	[enable_debug="no"]
	)
AS_IF([test "x$enable_debug" != "xno"],
	CFLAGS="-O0 -g -Wall"
	AC_DEFINE([DEBUG], [1], [Define to 1 if --enable-debug]),
	CFLAGS="-O2"
	)

AC_CONFIG_FILES([Makefile
                 src/Makefile])
AC_OUTPUT
